package com.wzs.workbench.web.controller;

import com.wzs.workbench.domain.Chapter;
import com.wzs.workbench.service.ChapterService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/chapter/")
public class chapterController {

    @Resource
    private ChapterService chapterService;

    @RequestMapping("save.do")
    @ResponseBody
    public boolean save(Chapter chapter){

        return chapterService.save(chapter);
    }

    @RequestMapping("delete.do")
    @ResponseBody
    public boolean delete(HttpServletRequest request) {
        System.out.println("执行到删除小说章节的操作");

        String[] ids = request.getParameterValues("id");

        return chapterService.delete(ids);
    }

    @RequestMapping("getChapterAll.do")
    @ResponseBody
    public Chapter getChapterAll(String id) {
        System.out.println("根据id查询单条小说章节信息");

        return chapterService.getChapterAll(id);
    }

    @RequestMapping("update.do")
    @ResponseBody
    public boolean update(Chapter chapter) {
        System.out.println("执行更新小说章节的操作");

        return chapterService.update(chapter);
    }

}
